package com.lie.prepare.multi_thread.task;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by lie on 2018/4/9.
 */
public class MainClass {

    public static void main(String[] args){
//        demo1();
        demo2();
    }

    //executor启动
    private static void demo2() {
        ExecutorService threadPool = Executors.newCachedThreadPool();
        threadPool.execute(new LiftOff());
        threadPool.execute(new LiftOff());
        threadPool.execute(new LiftOff());
        threadPool.execute(new LiftOff());
        threadPool.shutdown();
    }

    //main thread启动
    private static void demo1() {
//        new Thread(new LiftOff()).start();
//        new Thread(new LiftOff()).start();
//        new Thread(new LiftOff()).start();
//        new Thread(new LiftOff()).start();
        Thread t1 = new Thread(new LiftOff());
        Thread t2 = new Thread(new LiftOff());
        Thread t3 = new Thread(new LiftOff());
        Thread t4 = new Thread(new LiftOff());
        System.out.println(t1);
        System.out.println(t2);
        System.out.println(t3);
        System.out.println(t4);
//        Thread[Thread-0,5,main]
//        Thread[Thread-1,5,main]
//        Thread[Thread-2,5,main]
//        Thread[Thread-3,5,main]
        //他们都属于同一个线程组-main线程
    }
}
